//
//  SAAllocateDetailCell.m
//  saasRetail
//
//  Created by 黄志刚 on 2022/4/21.
//

#import "SAAllocateDetailCell.h"
#import "UILabel+NSMutableAttributedString.h"
#import "SAAllocateDetailModel.h"

@interface SAAllocateDetailCell ()

@property (nonatomic, strong) UIView *line;
@property (nonatomic, strong) UILabel *sizeColourLab;
@property (nonatomic, strong) UILabel *countLab;
@property (nonatomic, strong) UILabel *priceLab;
@property (nonatomic, strong) UILabel *totalLab;

@end

@implementation SAAllocateDetailCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

-(void)setModel:(dispatchSKUDetailModel *)model {
    _model = model;
    self.sizeColourLab.text = [NSString stringWithFormat:@"%@,%@",model.size,model.color];
    self.countLab.text = model.count;
    self.priceLab.text = [NSString stringWithFormat:@"%0.2lf",[model.price doubleValue]/100];
    self.totalLab.text = [NSString stringWithFormat:@"%0.2lf",[model.subtotal doubleValue]/100];
    
    NSString *productViewCostPrice = [NSString stringWithFormat:@"%@",[SAValueManger shareInStance].userInfo.menuList[1][@"perms"][@"productViewCostPrice"]];
    if ([productViewCostPrice isEqualToString:@"1"]) {
        self.priceLab.text = @"******";
        self.totalLab.text = @"******";
    }
}

-(void)initUI {
    
    UILabel *titleLab2 = [[UILabel alloc] initWithFrame:CGRectMake(kScaleNum(20), 0, kScaleNum(89), kScaleNum(40))];
    titleLab2.textColor = kBlackColor;
    titleLab2.font = kFont(15);
    titleLab2.textAlignment = NSTextAlignmentLeft;
    [self.contentView addSubview:titleLab2];
    self.sizeColourLab = titleLab2;
    
    UILabel *titleLab3 = [[UILabel alloc] initWithFrame:CGRectMake(kScaleNum(110), 0, kScaleNum(70), kScaleNum(40))];
    titleLab3.textColor = kBlackColor;
    titleLab3.font = kFont(15);
    titleLab3.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:titleLab3];
    self.countLab = titleLab3;
    
    UILabel *titleLab4 = [[UILabel alloc] initWithFrame:CGRectMake(kScaleNum(210), 0, kScaleNum(70), kScaleNum(40))];
    titleLab4.textColor = kBlackColor;
    titleLab4.font = kFont(15);
    titleLab4.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:titleLab4];
    self.priceLab = titleLab4;
    
    UILabel *titleLab5 = [[UILabel alloc] initWithFrame:CGRectMake(kScaleNum(290), 0, kScaleNum(80), kScaleNum(40))];
    titleLab5.textColor = kBlackColor;
    titleLab5.font = kFont(15);
    titleLab5.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:titleLab5];
    self.totalLab = titleLab5;
    
//    [self.contentView addSubview:self.line];
}

-(UIView *)line {
    if (!_line) {
        _line = [[UIView alloc] initWithFrame:SARectMake(0, 39, kBaseScreenWidth, 1)];
        _line.backgroundColor = kLineColor;
    }
    return _line;
}

@end
